//
//  YGFoodmanagerView.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/3/22.
//

#import "YGFoodmanagerView.h"


@interface YGFoodmanagerView ()

@property (nonatomic, strong)UILabel *foodLable;
@property(nonatomic, strong)UIImageView *foodImage;




@end
@implementation YGFoodmanagerView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initContraints];
                
    }
    return self;
    
}

- (void)initView{
    
    [self addSubview:self.foodBtn];
    [self addSubview:self.foodLable];
    [self addSubview:self.foodImage];
}


- (void)initContraints{
    
    [self.foodBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top);
        make.left.mas_equalTo(self.mas_left);
        make.width.mas_equalTo(self.mas_width);
        make.height.mas_equalTo(self.mas_height);
    }];
    
    [self.foodLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(15);
            make.left.mas_equalTo(self.mas_left).offset(10);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(16);
    }];
    
    [self.foodImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.foodBtn.mas_centerY);
            make.right.mas_equalTo(self.mas_right).offset(-15);
            make.height.mas_equalTo(75);
            make.width.mas_equalTo(72);
            
    }];
}


#pragma mark 点击事件
- (void)clickInfoFoodMannagerAction{
    
    if (self.foodMannagerViewdelegate != nil && [self.foodMannagerViewdelegate respondsToSelector:@selector(foodViewInfoFoodMannagerAction)]) {
        [self.foodMannagerViewdelegate foodViewInfoFoodMannagerAction];
    }
}

#pragma setter

- (UIButton *)foodBtn{
    if (!_foodBtn) {
        _foodBtn=[[UIButton alloc]init];
        _foodBtn.backgroundColor=UIColorFromRGB(0xFFE7E9);
        _foodBtn.layer.cornerRadius=5;
        [_foodBtn addTarget:self action:@selector(clickInfoFoodMannagerAction) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _foodBtn;
}

- (UILabel *)foodLable{
    if (!_foodLable) {
        _foodLable=[[UILabel alloc]init];
        _foodLable.text=@"膳食管理";
        _foodLable.textColor=UIColorFromRGB(0xE57B84);
        _foodLable.font=[UIFont fontWithName:@"Helvetica-Bold" size:16];
    }
    return _foodLable;
}

- (UIImageView *)foodImage{
    if (!_foodImage) {
        _foodImage= [[UIImageView alloc]init];
        [_foodImage setImage:[UIImage imageNamed:@"food_man_icon"]];
    }
    return _foodImage;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


@end
